import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:mybase/base/tool/file/FFile.dart';
import 'package:mybase/base/tool/platformUtils/FFPlatform.dart';
import 'package:mybase/base/tool/time/FFTime.dart';

class FFScript {
  static T? children<T>(T? Function() result) {
    return result();
  }
}

T? globalScript<T>(T? Function() result) {
  return result();
}

T globalScript2<T>(T Function() result) {
  return result();
}

///结束键盘输入
globalEndTextField(BuildContext context) {
  FocusScope.of(context).requestFocus(FocusNode());
}

///等待一小会:默认值不要改
Future<void> globalAwait({int mill = 300}) async {
  await Future.delayed(Duration(milliseconds: mill));
}

///输出日志到桌面文件log.log
global_log_file(String line, {String macos_user = "os"}) {
  if (kReleaseMode) return;
  if (FFPlatform.isIOS) {
    FFile.writeContentByPath(
      filePath: "/Users/${macos_user}/Desktop/log.log",
      content: FFTime.now().toString() + ": " + line + "\n",
      autoCreate: true,
    );
  }
}
